package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrderMapper {
    //保存订单
    @Insert("insert into orders values (null,#{number},1,#{userId},#{addressBookId},#{orderTime},#{checkoutTime},#{payMethod},#{amount},#{remark},#{phone},#{address},#{userName},#{consignee})")
    Integer add(Orders orders);
    //订单分页查询,查看最近订单
    @Select("select * from orders where user_id=#{userId}")
    List<Orders> findByPage(Long userId);
    //查询指定用户的总商品数量
    @Select("select count(*) from  orders where user_id=#{userId}")
    Integer count(Long userId);
    //再来一单
    @Select("select * from orders where id=#{id}")
    Orders again(Long id);
}
